
<!doctype html>
<html>
<head>
<title>科帮网在线考试本地存储Powered by 52itstyle</title>
<meta charset="utf-8" />
<script src="js/jquery-1.8.3.js"></script>
<script src="js/localstorage.js"></script>
<script src="js/jquery.utils.js"></script>
<script type="text/javascript">
var studentID = "007";
var ExamID = "52itstyle";
var quesNumber = 3;
$(function(){
  showQuestion();
  $("input").click(function(){
      var QuestionID = $(this).attr("name");
      var ExamAnswer = $(this).val();
      qext.LocalStorage.save(studentID,ExamID,QuestionID,ExamAnswer);
  });
});
/**
 * 读取本地存储答案并展示
 * 
 */
function showQuestion(){
  for(var i=1;i<=quesNumber;i++){
    var rst = getPerQuesInfo(i);
    if(null!=rst){
      var obj = eval("("+rst+")");  
      var examAnswer = obj.ExamAnswer;
      $("input[name="+i+"]").each(function(){
         if($(this).val()==examAnswer){
         $(this).attr("checked",true);
       }
      });
    }
  }
}
/**
 * 获取单个试题信息
 * 
 */
function getPerQuesInfo(QuestionID){
  var examKey = studentID+ExamID+QuestionID;
  var rst = qext.LocalStorage.get({
     key : examKey
  });
    return rst;
}
</script>
</head>
<body>
<div id="1">成吉思汗有几个老婆?</div>
<div>
<input type="radio" value="A" name="1" />A 1
<input type="radio" value="B" name="1"/>B 2 
<input type="radio" value="C" name="1"/>C 3
<input type="radio" value="D" name="1"/>D 4
</div>
<div>成吉思汗有几个老婆?</div>
<div>
<input type="radio" value="A" name="2" />A 1
<input type="radio" value="B" name="2"/>B 2 
<input type="radio" value="C" name="2"/>C 3
<input type="radio" value="D" name="2"/>D 4
</div>
<div>小伟有几个老婆?</div>
<div>
<input type="radio" value="A" name="3" />A 1
<input type="radio" value="B" name="3"/>B 2 
<input type="radio" value="C" name="3"/>C 3
<input type="radio" value="D" name="3"/>D 无数
</div>
<a href="http://www.52itstyle.com/">传送门</a>
</body>
</html>